<!DOCTYPE html>
<html lang="en">
<head>
        <meta charset="utf-8" />
        <title>PythonTutorials - Maxiaoan</title>
        <link rel="stylesheet" href="/theme/css/main.css" />

        <!--[if IE]>
            <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
        <![endif]-->
</head>

<body id="index" class="home">
        <header id="banner" class="body">
                <h1><a href="/">PythonTutorials </a></h1>
                <nav><ul>
                    <li><a href="/category/cpp.html">cpp</a></li>
                    <li><a href="/category/python.html">python</a></li>
                </ul>
                </nav>
        </header><!-- /#banner -->

                <section id="content" class="body">
                    <ol id="posts-list" class="hfeed" start="2">
            <li><article class="hentry">
                <header>
                    <h1><a href="/c-chapter5.html" rel="bookmark"
                           title="Permalink to chapter5">chapter5</a></h1>
                </header>

                <div class="entry-content">
<footer class="post-info">
        <span>Mon 06 April 2020</span>
<span>| tags: <a href="/tag/cpp.html">cpp</a><a href="/tag/progarmming.html">progarmming</a></span>
</footer><!-- /.post-info -->                <h1>循环结构</h1>
<h4>定义：从main()开始，从上向下，使得某些语句重复执行</h4>
<ul>
<li>控制（表达式）</li>
<li>基础语句（循环体）</li>
</ul>
<h4>循环结构的程序：在顺序语句中加入循环控制语句（3+1个）</h4>
<h4>循环控制语句(开关)</h4>
<ol>
<li>
<p>==方式1：while(表达式){循环体语句序列;}==</p>
<ol>
<li>while语句（当型循环）{循环体语句序列;} 后继语句</li>
<li>while整体为一条控制语句，注意执行过程</li>
<li>while后面的表达式需要加小括号</li>
<li>while控制一条语句(复合语句)</li>
<li>复合语句算一条语句</li>
<li>有可能一次都不执行（0次或者0次以上）</li>
<li>外面有初始值，括号内有条件表达式，循环体有增量。</li>
</ol>
</li>
<li>
<p>==方式2：do—while循环（直到型循环==）</p>
<ol>
<li>do{循环体语句序列；}while(表达式);后续语句</li>
<li>while加括号，后面有分号。</li>
<li>do不能单独出现，（else也不能单独出现）</li>
<li>do只能就近控制一条，如果多条 …</li></ol></li></ol>
                <a class="readmore" href="/c-chapter5.html">read more</a>
                </div><!-- /.entry-content -->
            </article></li>

            <li><article class="hentry">
                <header>
                    <h1><a href="/chapter10.html" rel="bookmark"
                           title="Permalink to chapter10">chapter10</a></h1>
                </header>

                <div class="entry-content">
<footer class="post-info">
        <span>Mon 06 April 2020</span>
<span>| tags: <a href="/tag/cpp.html">cpp</a><a href="/tag/progarmming.html">progarmming</a></span>
</footer><!-- /.post-info -->                <p># 一、位运算
 * 先将非二进制转换为二进制，然后还原为原来的进制
* 按位运算不存在借位
1. 位运算对象只能是整型或者字符型数据
2. C语言提供6中位运算符：
    1. &amp;    按位与
        * （1&amp;1=1, 1&amp;0=0, 0&amp;1=0，0&amp;0=0）
        * 有零为零，全1为1
        * 相当于按位乘
        * 作用：清零
    2. |    按位或
        * （（1|1=1, 1|0=1, 0|1=1，0|0=0））
        * 有1为1，全零为零
        * 相当于按位加
        * 位置重置为1
    3. ^    按位于或
        * （1\^1 …</p>
                <a class="readmore" href="/chapter10.html">read more</a>
                </div><!-- /.entry-content -->
            </article></li>

            <li><article class="hentry">
                <header>
                    <h1><a href="/chapter11.html" rel="bookmark"
                           title="Permalink to chapter11">chapter11</a></h1>
                </header>

                <div class="entry-content">
<footer class="post-info">
        <span>Mon 06 April 2020</span>
<span>| tags: <a href="/tag/cpp.html">cpp</a><a href="/tag/progarmming.html">progarmming</a></span>
</footer><!-- /.post-info -->                <h1>线性查找</h1>
<div class="highlight"><pre><span></span>int lineSearch(long num[],int x,int n)//线性查找
{
    for (int i=0;i&lt;n;i++)
    {
        if (num[i]==x)
            {
                return 1;
            }
    }
    return -1;
}
</pre></div>


<h1>二分法查找</h1>
<div class="highlight"><pre><span></span>int BinarySearch(long num[],int x,int n)//假设数组升序排序
{
    int low = 0,high = n-1,mid;
    while(low &lt;=high)//区间存在
    {
        mid=(high+low)/2;//mid …</pre></div>
                <a class="readmore" href="/chapter11.html">read more</a>
                </div><!-- /.entry-content -->
            </article></li>
            </ol><!-- /#posts-list -->
<p class="paginator">
        <a href="/author/maxiaoan17.html">&laquo;</a>
    Page 18 / 22
        <a href="/author/maxiaoan19.html">&raquo;</a>
</p>
            </section><!-- /#content -->
        <section id="extras" class="body">
                <div class="blogroll">
                        <h2>blogroll</h2>
                        <ul>
                            <li><a href="http://getpelican.com/">Pelican</a></li>
                            <li><a href="http://python.org/">Python.org</a></li>
                            <li><a href="http://jinja.pocoo.org/">Jinja2</a></li>
                            <li><a href="#">You can modify those links in your config file</a></li>
                        </ul>
                </div><!-- /.blogroll -->
                <div class="social">
                        <h2>social</h2>
                        <ul>

                            <li><a href="#">You can add links in your config file</a></li>
                            <li><a href="#">Another social link</a></li>
                        </ul>
                </div><!-- /.social -->
        </section><!-- /#extras -->

        <footer id="contentinfo" class="body">
                <p>Powered by <a href="http://www.maxiaoan.com/">Maxiaoan</a></p>
        </footer><!-- /#contentinfo -->

</body>
</html>